package com.vh.model;

import java.sql.Timestamp;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import org.appfuse.model.BaseObject;

@Entity(name="expense")
public class Expense extends BaseObject{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	Long id;
	Date doe;  //Date of expense	
	long storeId;
	String comments;
	String type; // C -> Cash , D -> Debit card , CC -> Credit Card
	Timestamp lastUpdTs;
	float amount;
	
	
	@Column(name="amount")
	public float getAmount() {
		return amount;
	}
	public void setAmount(float amount) {
		this.amount = amount;
	}
	
	@Column(name="date_of_entry")
	public Date getDoe() {
		return doe;
	}
	public void setDoe(Date doe) {
		this.doe = doe;
	}
	
	@Column(name="store_id")
	public long getStoreId() {
		return storeId;
	}
	public void setStoreId(long storeId) {
		this.storeId = storeId;
	}
	
	@Column(name="comments", length=200)
	public String getComments() {
		return comments;
	}
	public void setComments(String comments) {
		this.comments = comments;
	}
	
	@Column(name="type_of_exp", length=10)
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	
	@Column(name="lastUpdTs")
	public Timestamp getLastUpdTs() {
		return lastUpdTs;
	}
	public void setLastUpdTs(Timestamp lastUpdTs) {
		this.lastUpdTs = lastUpdTs;
	}
	
	@Id @GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Float.floatToIntBits(amount);
		result = prime * result
				+ ((comments == null) ? 0 : comments.hashCode());
		result = prime * result + ((doe == null) ? 0 : doe.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((lastUpdTs == null) ? 0 : lastUpdTs.hashCode());
		result = prime * result + (int) (storeId ^ (storeId >>> 32));
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Expense other = (Expense) obj;
		if (Float.floatToIntBits(amount) != Float.floatToIntBits(other.amount))
			return false;
		if (comments == null) {
			if (other.comments != null)
				return false;
		} else if (!comments.equals(other.comments))
			return false;
		if (doe == null) {
			if (other.doe != null)
				return false;
		} else if (!doe.equals(other.doe))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (lastUpdTs == null) {
			if (other.lastUpdTs != null)
				return false;
		} else if (!lastUpdTs.equals(other.lastUpdTs))
			return false;
		if (storeId != other.storeId)
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "Expense [id=" + id + ", doe=" + doe + ", storeId=" + storeId
				+ ", comments=" + comments + ", type=" + type + ", lastUpdTs="
				+ lastUpdTs + ", amount=" + amount + "]";
	}
	
	
	
	
	
	
	
	

}
